package com.fkcai.hansoul.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
	    
	    // 添加分页插件
	    PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
	    paginationInterceptor.setOverflow(true); // 超出总页数后回到第一页
	    paginationInterceptor.setMaxLimit(500L); // 单页最大记录数限制
	    
	    interceptor.addInnerInterceptor(paginationInterceptor);
	    return interceptor;
    }
}


